﻿/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __667E6A1A_6CE0_42d0_AC83_527D483B7AE8__
#define __667E6A1A_6CE0_42d0_AC83_527D483B7AE8__

#include "../tools/head.h"

/////////////////////////////////////////////////////////////////////////////////////////
// 

namespace xos
{
    // 
    // misc_impl
    // 
    class misc_impl : public xos_stl::mem_item< release_impl< misc_impl >, thread_lock >,
        public i_misc
    {
    public:
        typedef release_impl< misc_impl > T;

    public:
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //

        static int get_addr( POOL *** pppPool, LIST *** pppList );

    public:
        misc_impl();
        ~misc_impl();

    public:
        int init();
        int term();

    public:
        // 
        // utf8 to wchar
        // 
        int utf8_to_wchar( const char * lpszSrc, int nSrcByteSize, wchar_t * lpszDest, int nDestByteSize, int * lpnDestNeedSize );

        // 
        // wcharto utf8
        // 
        int wchar_to_utf8( const wchar_t * lpszSrc, int nSrcByteSize, char * lpszDest, int nDestByteSize, int * lpnDestNeedSize );

        // 
        // utf8 to ansi
        // 
        int utf8_to_ansi( const char * lpszSrc, int nSrcByteSize, char * lpszDest, int nDestByteSize, int * lpnDestNeedSize );

        // 
        // ansi utf8
        // 
        int ansi_to_utf8( const char * lpszSrc, int nSrcByteSize, char * lpszDest, int nDestByteSize, int * lpnDestNeedSize );

        // 
        // get process full file name
        // 
        int get_process_file_full_name( char * pszFile, int nLen, int * pnLenNeeded );

        // 
        // get process file path. including '\\' or '/'
        // 
        int get_process_path( char * pszPath, int nLen, int * pnLenNeeded );

        // 
        // get real path.
        // 
        int real_path( const char * lpszPath, char * lpszRealPath, int nSize );

        // 
        // append path in all platform
        // 
        int path_append( char * lpszPath, const char * lpszAdder );

        // 
        // url append
        // 
        int url_append( char * lpszUrl, const char * lpszAdder );

        // 
        // create guid
        // 
        int create_guid( char * lpszGuid );

        // 
        // sleep 1 / 1000 second
        // 
        int sleep( int nMilliseconds );

        // 
        // output debuf info
        // 
        int out_put_debug_string( const char * lpszInfo );
        int out_put_to_cmd( const char * lpszInfo );
        int trace( const char * lpszFormat, ... );

        // 
        // get seconds from since 1970-1-1
        // 
        xos_u64 get_wall_second( xos_u64 * lpWallSecond );

        // 
        // sys method
        // 
        xos_u64 get_current_process_id();
        xos_u64 get_current_thread_id();
        const char * platform();
        bool can_hot_replace();
        int get_cpu_num();
    };
} // xos

#endif // __667E6A1A_6CE0_42d0_AC83_527D483B7AE8__
